home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 1993 May / Info-Mac_II_May_1993.to_.sit / Info-Mac II (May 1993).toast / Unix / Skim-11.txt < prev    next >
Internet Message Format  |  1993-03-27  |  3KB

  1. From: macman@bernina.ethz.ch (Danny Schwendener)
  2. Subject: Browsing digests for recent uploads (version 1.1) 
  3. Date: Fri, 12 Feb 1993 13:57:18 GMT 
  4.  
  5. This is a slightly improved version of the skim Unix program recently
  6. posted by Craig Nevill-Manning <cgn@kauri.cs.waikato.ac.nz>. This version
  7. also inserts the necessary 'cd' and 'get' commands so that you can feed
  8. the resulting script directly into FTP.
  9.  
  10. I have sumex-aim in my .netrc file, so that all I need to do after the
  11. skim is to type the following command to get the tagged files:
  12.     ftp sumex-aim.stanford.edu < download
  13.  
  14. Craig Nevill-Manning <cgn@kauri.cs.waikato.ac.nz>'s program description:
  15. >
  16. >I wrote this quick Unix program for browsing info-mac digests. I try to keep
  17. >up with the new uploads to sumex, but it's a tedious, repetitive process to
  18. >actually download the stuff I want. This C program scans a digest (or several)
  19. >in a file or files given on the command line for the [*] denoting an upload
  20. >notice, and prints out the description. Type y if you want to download it, and
  21. >it adds the path and name to a file called "download". Typing n just continues
  22. >to the next message, and q quits the program. I then rearrange the file in
  23. >emacs, inserting cd and get commands, and paste it into an ftp session.
  24. >
  25. >Hope it's useful to someone! Remember, it was only a half-hour hack; feel free
  26. >to improve on it.
  27. >
  28. >Compile with cc -o skim skim.c -lcurses -ltermcap
  29. >or take out the curses stuff if you don't have it.
  30.  
  31.  
  32. -- Danny Schwendener                       E-mail: macman@bernina.ethz.ch
  33.    ezInfo Information Services, Swiss Fed. Institute of Technology (ETHZ)
  34.  
  35. skim.c (version 1.1) follows:
  36. ------------------------------ cut here ------------------------------ 
  37. /* skim.c Version 1.1 */
  38. #include <stdio.h>
  39. #include <curses.h>
  40.  
  41. FILE *download;
  42.  
  43. main(argc, argv)
  44. int argc;
  45. char **argv;
  46. {
  47.   int i;
  48.  
  49.   initscr();
  50.   cbreak();
  51.   
  52.  
  53.   download = fopen("download", "a");
  54.  
  55.   for (i = 1; i < argc; i ++)
  56.     skim(argv[i]);
  57.  
  58.   nocbreak();
  59.   endwin();
  60. }
  61.  
  62. skim(filename)
  63. char *filename;
  64. {
  65.   FILE *f;
  66.   char s[1000], path[1000];
  67.   char *name;
  68.   int ch, line;
  69.  
  70.   f = fopen(filename, "r");
  71.  
  72.   if (f) {
  73.     
  74.  
  75.     while (!feof(f)) {
  76.       do {
  77.     fgets(s, 1000, f);
  78.       } while (strncmp(s, "Subject: [*]", 12) != 0 && !feof(f));
  79.  
  80.       line = 0;
  81.  
  82.       path[0] = 0;
  83.  
  84.  
  85.       clear();
  86.       refresh();
  87.  
  88.       puts(filename);
  89.       while (!feof(f)) {
  90.     if (line ++ < LINES - 4)
  91.       printf("%s", s);
  92.     fgets(s, 1000, f);
  93.     if (strncmp(s, "[Archived as", 12) == 0) {
  94.       strcpy(path, &s[13]);
  95.       break;
  96.     }
  97.       }
  98.  
  99.       printf("%s", s);
  100.       
  101.  
  102.       if (path[0]) {
  103.     printf("Get this? (y/n)");
  104.  
  105.     do
  106.       ch = getchar();
  107.     while (ch != 'y' && ch != 'n' && ch != 'q');
  108.  
  109.     if (ch == 'y') {
  110.       int i;
  111.  
  112.       for (i = strlen(path); i > 0 && path[i] != ';'; i --); /* cut off trailer */
  113.       path[i] = 0;
  114.  
  115.       for (i = strlen(path); i > 0 && path[i] != '/'; i --); /* split into dir path & name */
  116.       name = &path[i+1];
  117.       path[i] = 0;
  118.       fprintf(download, "cd %s/\nget %s\n", path,name);
  119.     }
  120.     else if (ch == 'q') {
  121.       fclose(download);
  122.       nocbreak();
  123.       endwin();
  124.       exit(0);
  125.     }
  126.       }
  127.     }
  128.  
  129.     fclose(f);
  130.   }
  131. }
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.